import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommonStore } from '@/store';
import { CommontTypes, ResponseVo, GoodsTypes, GoodsStatusEnum } from '@/type';

export namespace GoodsService {
  export const pageGoods = async (data:GoodsTypes.PageGoodsType & CommontTypes.IPaginationParam): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/goods/page',{params:data, baseURL: BASE_API});
    return res;
  };

  export const addGoods = async (data:GoodsTypes.IGoodsItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/goods/add',data,{baseURL: BASE_API});
    return res;
  };

  export const editGoods = async (data:GoodsTypes.IGoodsItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/goods/edit',data,{baseURL: BASE_API});
    return res;
  };

  export const detailGoods = async (goodsCode:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/goods/detail',{params:{goodsCode}, baseURL: BASE_API});
    return res;
  };

  export const updateGoodsStatus = async (goodsCode:number,status:GoodsStatusEnum): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/goods/updateStatus',{params:{goodsCode,status}, baseURL: BASE_API});
    return res;
  };

  export const deleteGoods = async (goodsCode:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/goods/delete',{params:{goodsCode}, baseURL: BASE_API});
    return res;
  };
}
